#ifndef MAPPERSXROM_H
#define MAPPERSXROM_H

#include "Mapper.h"
PNE_NAMESPACE_BEGIN

struct MapperSxROM : public Mapper
{
    MapperSxROM(Cartridge &cart, std::function<void(void)> mirroring_callback);
    void WritePRG(Address addr, Byte value);
    Byte ReadPRG(Address addr);
    Byte ReadCHR(Address addr);
    void WriteCHR(Address addr, Byte value);

    NameTableMirroring GetNameTableMirroring();

private:
    void calculatePRGPointers();
    std::function<void(void)> m_mirroringCallback;
    NameTableMirroring m_mirroring;

    bool m_usesCharacterRAM;
    int m_modeCHR;
    int m_modePRG;

    Byte m_tempRegister;
    int m_writeCounter;

    Byte m_regPRG;
    Byte m_regCHR0;
    Byte m_regCHR1;

    const Byte *m_firstBankPRG;
    const Byte *m_secondBankPRG;

    const Byte *m_firstBankCHR;
    const Byte *m_secondBankCHR;

    std::vector<Byte> m_characterRAM;
};

PNE_NAMESPACE_END

#endif // MAPPERSXROM_H

// DONE